<?php 
include 'security.inc';

//set root_path and root_url in session
if (basename($_SERVER["SCRIPT_FILENAME"]) == "index.php") {
    if (!isset($_SESSION["root_path"]))
        $_SESSION["root_path"] = dirname($_SERVER["SCRIPT_FILENAME"]);
        //$_SESSION["root_path"] = "have";
    if (!isset($_SESSION["root_url"]))
        $_SESSION["root_url"] = str_replace ('\\','',dirname($_SERVER["PHP_SELF"]));
}



//echo $_SESSION["root_url"]."Sophea";

if (isset($_GET["debug"])) $_SESSION["debug"]=$_GET["debug"];
if (isset($_GET["logout"])) {
	unset($_SESSION["user"]); 
	unset($_SESSION["user_roles"]); 
	unset($_SESSION["campaign_id"]);
	unset($_SESSION["campaign_name"]);
	header('Location: index.php');
	die(); 
}
if (isset($_GET["exit_campaign"])) {
	unset($_SESSION["campaign_id"]);
	unset($_SESSION["campaign_name"]);
	header('Location: index.php');
	die(); 
}
$_SESSION["session_timestamp"] = time();
?>
<html>
<head>
 <title>Selection Tool (Light Version)</title>
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 <script type='text/javascript' src='<?php if (isset($_SESSION["root_url"])) echo $_SESSION["root_url"];?>/datepicker.js'></script>
 <script type='text/javascript' src='<?php if (isset($_SESSION["root_url"])) echo $_SESSION["root_url"];?>/script/script.js'></script>

 <link rel=stylesheet href="<?php if (isset($_SESSION["root_url"])) echo $_SESSION["root_url"];?>/style.css" type="text/css" />
</head>
<body>
<?php if (isset($_SESSION["user"])) { ?>
<a href="<?php echo $_SESSION["root_url"]?>/index.php"><img src='<?php echo $_SESSION["root_url"]?>/images/home.gif' hspace=1 vspace=0 style='vertical-align:bottom' border=0/>Home Page</a>
 &nbsp; 
<?php
//echo "sophea ".$_SESSION["root_url"]."<br />";

if (isset($_SESSION["user"])) {
	echo "Welcome ".$_SESSION["user_first_name"]." ".$_SESSION["user_last_name"]."!";
	echo " <a href='".$_SESSION["root_url"]."/index.php?logout'><img src='".$_SESSION["root_url"]."/images/logout.gif' hspace=1 vspace=0 style='vertical-align:bottom' border=0/>Logout</a>";
	echo " &nbsp; ";
}
if (isset($_SESSION["campaign_name"])) {
	echo "You are working on selection campaign <b>".$_SESSION["campaign_name"]."</b>";
	echo " <a href='".$_SESSION["root_url"]."/index.php?exit_campaign'>Change campaign</a>";
}
?>
<hr width="100%" style='margin:0px;padding:0px;margin-top:2px;margin-bottom:1px'/>
<?php } ?>